package com.guijq.selfcode.javase;

/**
 * @author yangjf
 * @time 2019-06-18 11:24
 * //插入排序
 */
public class Test87 {


    public static void main(String[] args) {
        int[] array = {8, 4, 2, 3, 5};

        for (int i = 1; i < array.length; i++) {
            int temp = array[i];
            int dest = i;
            for (int j = i - 1; j >= 0; j--) {
                if (array[j] > temp) {
                    array[j + 1] = array[j];
                    dest = j;
                }
            }
            array[dest] = temp;
        }

        for (int k : array) {
            System.out.println(k);
        }

    }

}
